# import requests
# from bs4 import BeautifulSoup
# from selenium import webdriver
# import time
# url = 'http://47.103.13.124:8001/brower'
# header = {
#     'User-Agent':' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36',
# }

# params = {
#         'colorDepth': '24',
#         'cookieEnabled': 'true',
#         'cpus': '4',
#         'platform': 'Win32',
#         'pluginNum': '3',
#         'screenHeight': '1200',
#         'screenWdith': '1920',
#         'timezone': '-480'
# }
# cookie ={
#     'session':'.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMTGGQ.MMAqCUnB1OPOnmrBP6QnQryjT8I'
# }
# # padload = {cpus:navigator.hardwareConcurrency // 8}

# # Object.defineProperty(window.navigator, 'hardwareConcurrency', {value: 12}) 
# # navigator.hardwareConcurrency // 12

# # brower  = requests.get(url,headers=header,cookies=cookie)
# brower  = requests.post(url,cookies=cookie,headers=header)
# # b = BeautifulSoup(brower.text,'lxml')
# # print(b)

# print(brower)
# # brower = webdriver.Chrome(executable_path='chromedriver.exe')
# # brower.get(url,header=header,cookie=cookie)
# # # time.sleep(10)
# # e = brower.find_element_by_class_name('move-list').find_element_by_tag_name('a')
# # for i in e:
# #     print(i)
# # time.sleep(18)
# --------------------------分割线--------------------------------------------

from selenium.webdriver import Chrome

import time
brower = Chrome()
brower.get('http://47.103.13.124:8001/brower')
script = ''

from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
# 可以对网页上元素是否存在，可点击等等进行判断，一般用于断言或与WebDriverWait配合使用。
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver import Chrome
from selenium.webdriver import ChromeOptions

option = ChromeOptions()
# 设置了下面这个就可以爬取了啊，直接无视了浏览器特征识别
option.add_experimental_option('excludeSwitches',['enable-authmation'])
brower = Chrome(options=option)
# brower = webdriver.Chrome(executable_path="chromedriver.exe")
url = "http://47.103.13.124:8001/sign"
# url = "http://47.103.13.124:8001/iframe_out"
# brower.get(url)
# brower.add_cookie({'name':'session','value':'.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMSFxw.zqmqHWReTQy-hZrWiGfXnUzvbZA'})
# brower.get(url)
def wait_element(brower,element_id,wait_time=10):
    try:
        # 调用该方法提供的驱动程序作为参数，直到返回值为True
        WebDriverWait(brower,wait_element,1).until(
            # 判断是否至少有1个元素存在于dom树中。
            # 举个例子，如果页面上有n个元素的class都是'column-md-3'，那么只要有1个元素存在，这个方法就返回True
            EC.presence_of_all_elements_located((By.ID,element_id))
        )
    except Exception as e:
        raise Exception(e)

try:
    brower.get(url)
    brower.add_cookie({'name':'session','value':'.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMSFxw.zqmqHWReTQy-hZrWiGfXnUzvbZA'})
    brower.get(url)
    myframe = brower.find_elements_by_class_name('mb-1')
    # myframe = brower.find_element_by_tag_name('p').text
    # myframe = brower.find_element_by_css_selector('p')
    # print(myframe.text)
    for i in myframe:
    # brower.find_elements_by_tag_name
        # print(i.get_attribute('src'))
        print(i.text)



    # brower.switch_to.frame(myframe)
    # input = 'inputEmail'
    # # wait_element(brower,input)
    # user = brower.find_element_by_id(input)
    # user.clear()
    # # user.click()
    # user.send_keys('user')

    # # time.sleep(2)
    # p = 'inputPassword'
    # # wait_element(brower,p)
    # padd = brower.find_element_by_id(p)
    # # padd.click()
    # padd.clear()
    # padd.send_keys('password')

    # # brower.switch_to.parent_frame(myframe)
    # button = brower.find_element_by_tag_name('div').find_element_by_tag_name('button')
    # button.click()
    # print('已经点击')
finally:
    time.sleep(10)
    print('end')
    brower.close()

# --------------------------分割线--------------------------------------------
# import requests

# cookies ={
#     'session':'.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMTGGQ.MMAqCUnB1OPOnmrBP6QnQryjT8I; canvas=dcf1a270150000798f0d7c2412d20af6'
# }
# headers = {
#     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"
# }
# url = "http://47.103.13.124:8001/sign"
# # url = "http://47.103.13.124:8001/brower"
# param = {
#     "userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",
#     "colorDepth": 24,
#     "cookieEnabled": True,
#     "cpus": 4,
#     "platform": "Win32",
#     "pluginNum": 3,
#     "screenHeight": 1200,
#     "screenWdith": 1920,
#     "timezone": -480
# }
# r = requests.post(url,cookies=cookies,headers=headers)
# # r = requests.get(url,cookies=cookies)
# print(r.json())
















